import CodeBlock from "@/components/code-block"

function extractCode(snippet) {
    const codeMatch = snippet.match(/```python([\s\S]*?)```/);
    return codeMatch ? codeMatch[1].trim() : '';
}


export function Block({ message }) {
    console.log(message);

    let codeString = `
    Sure, here is an example code snippet in Python: \`\`\`python # Define a function that calculates the square of a number def square(num): return num ** 2 # Take user input for a number num = int(input("Enter a number: ")) # Print the square of the input number print(f"The square of {num} is {square(num)}") \`\`\` This code takes user input for a number, calculates the square of that number using a function, and then prints the result.
  `;
    codeString = extractCode(codeString)
    return (
        
            <>
                <div className=" ">{message}</div>
                <div>
                    <CodeBlock language="javascript" value={codeString}>
                    </CodeBlock>
                </div>
                <div className="p-2">{message}</div>
                </>
        

    );
}
